import { FactoryTaskHelper } from "GameLoop/WorldState/EntityManager/Entitys/room/factory/FactoryTaskHelper"
import { priority } from "utils/constants/definetypes"
import { generateUniqueId } from "utils/utils"

export class CoreTaskHelper
{
    public static getProduce(resourceType: CommodityConstant,amount:number,p:number=priority.D)
    {
       
        const task:ITask<IFactoryTaskData<"produce">>={
            id:generateUniqueId(),
            priority:p,
            ttl:-1,
            type:"factory",
            data:{
                type:"produce",
                arg: FactoryTaskHelper.getProduceTaskArg(resourceType,amount),
            },
            shard: 1,
        }
        return task
    }

    public static getSend(from:string,to:string,resourceType: ResourceConstant,amount:number,p:number=priority.D)
    {
        const task:ITask<ITerminalTaskData<"send">>={
            id:`${from}_${to}_${resourceType}`,// generateUniqueId(),
            priority:p,
            ttl:-1,
            type:"terminal",
            data:{
                type:"send",
                arg:{
                    From: from,
                    To: to,
                    Resource: {
                        resourceType:resourceType,
                        amount:amount
                    }
                },
            },
            shard: 1,
        }
        return task;
    }

    public static getDeal<T extends "buy"|"sell">(orderid:string,type:T,amount:number,ttl:number=300,p:number=priority.D)
    {
        const task:ITask<ITerminalTaskData<T>>={
            id:generateUniqueId(),
            priority:p,
            ttl:-1,
            type:"terminal",
            data:{
                type:type,
                arg:{
                    orderId:orderid,
                    amount:amount
                },
            },
            shard: 1,
        }
        return task;
    }
}